<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动态表格</title>
</head>
<body>
<table border="1px">
    <thead>
    <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Age</th>
    </tr>
    </thead>
    <tbody id="userInfo">


    </tbody>
</table>
<script type="text/javascript">
    //道理一样 不是写死了的
    info1 = {ID: 1001, Name: "Alan", Age: 16}
    info2 = {ID: 1002, Name: "Bob", Age: 17}

    var userLt = [info1,info2];
    // 举一反三！！！
    var tbodyTag = document.getElementById("userInfo");

    for (var user in userLt) {
        var info = userLt[user];
        var trTag = document.createElement("tr");
        for (var i in info) {
            var thTag = document.createElement("th");
            thTag.innerText = info[i];
            trTag.appendChild(thTag);
        }
        tbodyTag.appendChild(trTag);
    }


</script>


</body>
</html>